
export function drawVideoToCanvas(video, smallLength, imageSmoothingEnabled){
  const c = document.createElement('canvas');
  let w = video.videoWidth
  let h = video.videoHeight
  if (smallLength) {
    // 根据短边的长度缩小画布，ocr处理太大的像素很慢
    const scale = w / h
    if (w > h) {
      h = smallLength
      w = Math.floor(h * scale)
    } else {
      w = smallLength
      h = Math.floor(w / scale)
    }
  }
  c.width = w;
  c.height = h;
  const ctx = c.getContext('2d')
  ctx.imageSmoothingEnabled = imageSmoothingEnabled || false // 开启这个，ocr耗时减40%（smallLength=200的情况下）
  ctx.drawImage(video, 0, 0, c.width, c.height);
  return [c, ctx]
}